#

| Chapter 18 Linking, Renaming, and Copying Files |

## 18.12 Renaming a List of Files Interactively

Article 18.9 shows how to rename a set of files, like changing `*.new` to `*.old`. Here's a different way, done from inside vi. This gives you a chance to review and edit the commands before you run them. Here are the steps:

    &amp;amp;
    $
    % vi   Start vi without a filename
    :r !ls *.new   Read in the list of files, one filename per line
    :%s/.*/mv & &/ Make mv command lines
    :%s/new$/old/   Change second filenames; ready to review
    :w !sh   Run commands by writing them to a shell
    :q!   Quit vi without saving

If you've made an alias (10.2) for ls that changes its output format, that can cause trouble here. If your alias gives more than a plain list of filenames in a column, use `!/bin/ls` instead of just `!ls`.

- JP

18.11 Renaming Files with ren |  | 18.13 One More Way to Do It